//
//  test_rdf.cpp
//  cobalt
//
//  Created by Nicolas Godbout on 2013-08-26.
//  Copyright (c) 2013 Nicolas Godbout. All rights reserved.
//

//#include "test_rdf.h"

#include "../cobalt/rdf/environment.h"
#include "../cobalt/vocabulary.h"
#include "gtest/gtest.h"

namespace rdf {
    
class NodeTest : public ::testing::Test {
protected:
    static rdf::Environment       *env;
    static rdf::RDFNode           *nodes;

    NodeTest() {}
    
    virtual ~NodeTest() {}
    
    virtual void SetUp() {}
    virtual void TearDown() {}
    
    static void SetUpTestCase() {
        env = new rdf::Environment();
        nodes = new rdf::RDFNode [13]
        {
            env->createBlankNode(),
            env->createBlankNode(),
            env->createNamedNode("http://example.org/resource1"),
            env->createNamedNode("http://example.org/resource2"),
            env->createNamedNode("http://example.org/resource3"),
            env->createLiteral("Hello",env->createNamedNode("http://example.org/resource2")),
            env->createLiteral("Hall of fame", vocab::xsd::string),
            env->createLiteral("Hello", vocab::xsd::string),
            env->createLiteral("Hello","en-us"),
            env->createLiteral("Hello!","en-us"),
            env->createLiteral("Hullo","en-us"),
            env->createLiteral("Hello","fr-ca"),
            env->createNamedNode("http://example.org/resource2")
        };
    }
    
    static void TearDownTestCase() {
        delete [] nodes;
        delete env;
    }
};

rdf::Environment* NodeTest::env;
rdf::RDFNode* NodeTest::nodes;


TEST_F(NodeTest, NodeEquality) {
    ASSERT_EQ(nodes[0], nodes[0]);
    ASSERT_EQ(nodes[1], nodes[1]);
    ASSERT_EQ(nodes[2], nodes[2]);
    ASSERT_EQ(nodes[3], nodes[3]);
    ASSERT_EQ(nodes[4], nodes[4]);
    ASSERT_EQ(nodes[5], nodes[5]);
}

TEST_F(NodeTest, NodeInequality) {
    ASSERT_NE(nodes[0], nodes[1]);
    ASSERT_NE(nodes[0], nodes[2]);
    ASSERT_NE(nodes[0], nodes[3]);
    ASSERT_NE(nodes[0], nodes[4]);
    ASSERT_NE(nodes[0], nodes[5]);
    ASSERT_NE(nodes[4], nodes[5]);
    ASSERT_NE(nodes[3], nodes[5]);
}

TEST_F(NodeTest, BlankNamedOrdering) {
    EXPECT_LT(nodes[0], nodes[2]);
    EXPECT_LT(nodes[0], nodes[3]);
    EXPECT_LT(nodes[0], nodes[4]);
    EXPECT_LT(nodes[1], nodes[2]);
    ASSERT_FALSE(nodes[2] < nodes[0]);
    ASSERT_FALSE(nodes[3] < nodes[0]);
    ASSERT_FALSE(nodes[4] < nodes[0]);
    ASSERT_FALSE(nodes[2] < nodes[1]);
}

TEST_F(NodeTest, BlankLiteralOrdering) {
    EXPECT_LT(nodes[0], nodes[5]);
    EXPECT_LT(nodes[1], nodes[5]);
}

TEST_F(NodeTest, NamedLiteralOrdering) {
    EXPECT_LT(nodes[2], nodes[5]);
    EXPECT_LT(nodes[3], nodes[5]);
    EXPECT_LT(nodes[4], nodes[5]);
}

TEST_F(NodeTest, BlankOrdering) {
    EXPECT_LT(nodes[0],nodes[1]);
}

TEST_F(NodeTest, NamedOrdering) {
    EXPECT_LT(nodes[2],nodes[3]);
    EXPECT_LT(nodes[2],nodes[4]);
    EXPECT_LT(nodes[3],nodes[4]);
}

TEST_F(NodeTest, LiteralOrdering) {
    EXPECT_LT(nodes[5], nodes[6]);
    EXPECT_LT(nodes[5], nodes[7]);
    EXPECT_LT(nodes[5], nodes[8]);
    EXPECT_LT(nodes[5], nodes[9]);
    EXPECT_LT(nodes[5], nodes[10]);
    EXPECT_LT(nodes[5], nodes[11]);
    EXPECT_LT(nodes[6], nodes[7]);
    EXPECT_LT(nodes[6], nodes[8]);
    EXPECT_LT(nodes[6], nodes[9]);
    EXPECT_LT(nodes[6], nodes[10]);
    EXPECT_LT(nodes[6], nodes[11]);
    EXPECT_LT(nodes[7], nodes[8]);
    EXPECT_LT(nodes[7], nodes[9]);
    EXPECT_LT(nodes[7], nodes[10]);
    EXPECT_LT(nodes[7], nodes[11]);
    EXPECT_LT(nodes[8], nodes[9]);
    EXPECT_LT(nodes[8], nodes[10]);
    EXPECT_LT(nodes[8], nodes[11]);
    EXPECT_LT(nodes[9], nodes[10]);
    EXPECT_LT(nodes[9], nodes[11]);
    EXPECT_LT(nodes[10], nodes[11]);
}

TEST_F(NodeTest, PointerEquality) {
    EXPECT_EQ(nodes[3].node, nodes[12].node);
}

/*
TEST_F(RDFNodeTest, NodeWildcard) {
    EXPECT_EQ(rdf::Node(), nodes[0]);
    EXPECT_EQ(rdf::Node(), nodes[2]);
    EXPECT_EQ(rdf::Node(), nodes[5]);
    EXPECT_EQ(rdf::Node(), nodes[7]);
    EXPECT_EQ(rdf::Node(), nodes[11]);
}
*/

}